# -*- coding:utf-8 -*-
from __future__ import absolute_import, unicode_literals

"""
本文件记录数据库相关配置
"""

# 数据库配置
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.mysql",
        "NAME": "wenlincms",
        "USER": "wenlincms",
        "PASSWORD": "wenlincms",
        "HOST": "",
        "PORT": "",
        # 设置MySql 5.5.27默认的储存引擎（在mysql中设置较好）
        # 'OPTIONS': {'init_command': 'SET table_type=MyISAM;'},
    }
}

# 配置多数据库路由规则，实现读写分离等操作
# class MasterSlaveRouter(object):
#     def db_for_read(self, model, **hints):
#         return 'slave'
#
#     def db_for_write(self, model, **hints):
#         return 'default'
#
#     def allow_relation(self, obj1, obj2, **hints):
#         db_list = ('default', 'slave')
#         if obj1._state.db in db_list and obj2._state.db in db_list:
#             return True
#         return None
#
#     def allow_syncdb(self, db, model):
#         return False

# 如需启用配置的多数据库路由规则，则反注释掉下面语句
# DATABASE_ROUTERS = ['mainsys.dbrouters.MasterSlaveRouter']
